package com.dianping.cat.alarm.receiver.transform;

import com.dianping.cat.alarm.receiver.entity.AlertConfig;
import com.dianping.cat.alarm.receiver.entity.Receiver;
import org.xml.sax.Attributes;




public class DefaultSaxMaker
  extends Object
  implements IMaker<Attributes>
{
  public AlertConfig buildAlertConfig(Attributes attributes) {
/* 15 */     String enable = attributes.getValue("enable");
/* 16 */     AlertConfig alertConfig = new AlertConfig();

/* 18 */     if (enable != null) {
/* 19 */       alertConfig.setEnable((Boolean)convert(Boolean.class, enable, null));
    }

/* 22 */     return alertConfig;
  }



/* 27 */   public String buildDx(Attributes attributes) { throw new UnsupportedOperationException(); }




/* 32 */   public String buildEmail(Attributes attributes) { throw new UnsupportedOperationException(); }




/* 37 */   public String buildPhone(Attributes attributes) { throw new UnsupportedOperationException(); }



  public Receiver buildReceiver(Attributes attributes) {
/* 42 */     String id = attributes.getValue("id");
/* 43 */     String enable = attributes.getValue("enable");
/* 44 */     Receiver receiver = new Receiver(id);

/* 46 */     if (enable != null) {
/* 47 */       receiver.setEnable((Boolean)convert(Boolean.class, enable, null));
    }

/* 50 */     return receiver;
  }



/* 55 */   public String buildWeixin(Attributes attributes) { throw new UnsupportedOperationException(); }



  protected <T> T convert(Class<T> type, String value, T defaultValue) {
/* 60 */     if (value == null || value.length() == 0) {
/* 61 */       return defaultValue;
    }

/* 64 */     if (type == Boolean.class || type == boolean.class)
/* 65 */       return (T)Boolean.valueOf(value); 
/* 66 */     if (type == Integer.class || type == int.class)
/* 67 */       return (T)Integer.valueOf(value); 
/* 68 */     if (type == Long.class || type == long.class)
/* 69 */       return (T)Long.valueOf(value); 
/* 70 */     if (type == Short.class || type == short.class)
/* 71 */       return (T)Short.valueOf(value); 
/* 72 */     if (type == Float.class || type == float.class)
/* 73 */       return (T)Float.valueOf(value); 
/* 74 */     if (type == Double.class || type == double.class)
/* 75 */       return (T)Double.valueOf(value); 
/* 76 */     if (type == Byte.class || type == byte.class)
/* 77 */       return (T)Byte.valueOf(value); 
/* 78 */     if (type == Character.class || type == char.class) {
/* 79 */       return (T)Character.valueOf(value.charAt(0));
    }
/* 81 */     return (T)value;
  }
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/lib/cat-alarm-3.0.0.jar!/com/dianping/cat/alarm/receiver/transform/DefaultSaxMaker.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */